new Vue({
    el: "#wap_pro",
    data() {
        return {
            services: services,
            currResumeId:'',
            projects:'',
            currIndex:'',
            currId:'',
            currProName:'',
            currProDuty:'',
            currWorkContext:'',
        }
    },
    created () {
        this.currResumeId = $.cookie('resumeId');
        var storage=window.localStorage;
        this.projects = JSON.parse(storage.projects);
        this.currId = GetQueryString('id');
        this.currIndex= GetQueryString('index');
        this.currProName = this.projects[this.currIndex].projectName;
        this.currProDuty = this.projects[this.currIndex].duties;
        this.currWorkContext = this.projects[this.currIndex].workContext;
    },
    methods:{
        savePro:function () {
            if(this.currProName==''||this.currProName==null){
                layerMsg("项目名字不可以为空");
                return
            }
            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceProject"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "id": that.currId
                    ,"resumeId": that.currResumeId
                    ,"projectName": that.currProName
                    ,"duties": that.currProDuty
                    ,"workContext": that.currWorkContext
                })
                ,success:function(res){
                    console.log(res)
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            window.location.href="my-resume.html" ;
                        },500);
                    }

                }
            });
        },
        deletePro:function () {
            var that = this;
            layer.confirm('删除后无法恢复，确认要删除吗', {title:false,closeBtn:0,scrollbar: false}, function(index){
                $.ajax({
                    url:that.services+"/user/resume/experienceProject/"+that.currId
                    ,type:"delete"
                    ,contentType:"application/json;charset=utf-8"
                    ,xhrFields: {
                        withCredentials: true
                    }
                    ,crossDomain: true
                    ,success:function(res){
                        if(res.success){
                            var check = ApiLoginStatus(res);
                            if(check==false)
                                return false;
                            layerMsg(res.message);
                            setTimeout(function() {
                                window.location.href="my-resume.html" ;
                            },500);
                        }
                    }
                });
                layer.close(index);
            });
        }
    }
});